home *** CD-ROM | disk | FTP | other *** search
- /*
- File: PartUtils.cpp
-
- Contains: Part utility functions & classes
-
- Written by: PartMaker
-
- Change History (most recent first):
-
- <4> 4/19/95 RB Mods for b1c18 compliance.
- <3+> 2/18/95 SJF Place code in CAProxyPart segment unconditionally
- <3> 2/13/95 SJF Interim checkin to update project database
- <0> 11/16/94 SJF first written
-
- To Do:
- implement
- */
-
- #ifndef _ALTPOINT_
- #include <AltPoint.h> /* Must come before other OpenDoc includes */
- #endif
-
- #ifndef _EXCEPT_
- #include <Except.h>
- #endif
-
- #ifndef _ODTYPES_
- #include <ODTypes.h> // MUST BE BEFORE TOOLBOX INCLUDES
- #endif
-
- #ifndef _CAPROXYPART_
- #include "CAProxyPart.h"
- #endif
-
- #ifndef __RESOURCES__
- #include <Resources.h>
- #endif
-
- #ifndef __TOOLUTILS__
- #include <ToolUtils.h>
- #endif
-
- #ifndef __DIALOGS__
- #include <Dialogs.h>
- #endif
-
- #ifndef SOM_ODWindow_xh
- #include <Window.xh>
- #endif
-
- #ifndef SOM_ODSession_xh
- #include <ODSessn.xh>
- #endif
-
- #ifndef SOM_ODDispatcher_xh
- #include <Disptch.xh>
- #endif
-
- #ifndef _PARTUTILS_
- #include "PartUtils.h"
- #endif
-
- #ifndef __CONTROLS__
- #include <Controls.h>
- #endif
-
- //#ifdef applec
- #pragma segment CAProxyPart
- //#endif
-
-
- //--------------------------------------------------------------------
- // MyDialogFilter
- //--------------------------------------------------------------------
-
- pascal Boolean
- MyDialogFilter(DialogPtr dialog, EventRecord* event, short* itemHit)
- {
- ODBoolean handled = kODFalse;
-
- if (event->what == nullEvent ||
- event->what == updateEvt && (WindowPtr) event->message != dialog ||
- event->what == activateEvt && (WindowPtr) event->message != dialog)
- {
- Environment *ev = somGetGlobalEnvironment();
- gSession->GetDispatcher(ev)->Dispatch(ev,(ODEventData*)event);
- }
- else if ((event->what == keyDown) || (event->what == autoKey))
- {
- #define kMyButtonDelay 8
- long waitTicks;
- short itemKind;
- Handle itemHandle;
- Rect itemRect;
- char key = (char)(event->message & charCodeMask);
- const char kReturnKey = 13;
- const char kEnterKey = 3;
- const char kEscKey = 27;
-
- switch(key)
- {
- case kReturnKey:
- case kEnterKey:
- *itemHit = ok;
- GetDialogItem(dialog,ok,&itemKind,&itemHandle,&itemRect);
- HiliteControl((ControlHandle)itemHandle,kControlButtonPart);
- Delay(kMyButtonDelay,&waitTicks);/* wait about 8 ticks */
- HiliteControl((ControlHandle)itemHandle,kODFalse);
- handled = kODTrue;
- break;
- case kEscKey:
- *itemHit = cancel;
- GetDialogItem(dialog,cancel,&itemKind,&itemHandle,&itemRect);
- HiliteControl((ControlHandle)itemHandle,kControlButtonPart);
- Delay(kMyButtonDelay,&waitTicks);
- HiliteControl((ControlHandle)itemHandle,kODFalse);
- handled = kODTrue;
- break;
- }
- }
-
- return handled;
- }
-
-
- //-------------------------------------------------------------------------------------
- // GetWindowPoint
- //-------------------------------------------------------------------------------------
-
- void
- GetWindowPoint(ODWindow *w, Environment *ev,
- Point globalPoint,
- ODPoint *localPoint)
- {
- GrafPtr curPort;
- GetPort(&curPort);
- SetPort(w->GetPlatformWindow(ev));
- SetOrigin(0,0);
- GlobalToLocal(&globalPoint);
- SetPort(curPort);
- *localPoint = globalPoint;
- }
-